home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 544 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  49 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: dirk@sallust.ida.ing.tu-bs.de (Dirk Herrmann)
  3. Newsgroups: comp.std.c++
  4. Subject: Q: default constructor for fundamental types?
  5. Date: 26 Feb 1996 09:24:07 PST
  6. Organization: TU Braunschweig, Informatik (Bueltenweg), Germany
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4glrdc$dqo@ra.ibr.cs.tu-bs.de>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 24 Feb 1996 01:59:08 GMT
  11. X-Newsreader: TIN [version 1.2 PL2]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMTHsyky4NqrwXLNJAQGISgH/XdWyYTiKkXMhNszr+SBKzhZbaQstrHCH
  14.     gtqTNybiimiq2ZBFRHp2KHRCBtMq5OWUiFpeUoQSLJbnwKM3T9TOHQ==
  15.     =CTEk
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. Sorry if this has been discussed before.
  19.  
  20. When using templates, it appears that there should be
  21. default constructors for the fundamental data types.
  22.  
  23. Example:
  24.  
  25. template <class T>
  26. X {
  27.   public:
  28.     X() : t() {};
  29.     X(const T& tt) : t(tt) {};
  30.  
  31.   private:
  32.     T t;
  33. }
  34.  
  35. As far as i know, the default constructor of
  36. e.g. X<int> would not compile since there is no default
  37. constructor for an int value.
  38. It seems to be a pity that this would not be allowed.
  39.  
  40. --
  41. Dirk Herrmann
  42. ---
  43. [ To submit articles: Try just posting with your newsreader.  If that fails,
  44.                       use mailto:std-c++@ncar.ucar.edu
  45.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  46.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  47.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  48. ]
  49.